<!--
 * @Description: 
 * @version: 
 * @Author: 尹鹏孝
 * @Date: 2022-01-24 08:58:40
 * @LastEditors: 尹鹏孝
 * @LastEditTime: 2022-01-24 09:12:22
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>赎金信</title>
</head>

<body>
    <script>
        // 赎金信
        var canConsTruct = function (ransomNote, magazine,) {
            const strArr = new Array(26).fill(0),
                base = 'a'.charCodeAt();
            for (const s of magazine) {
                strArr[s.charCodeAt() - base]++;
            }

            for (const s of ransomNote) {
                const index = s.charCodeAt() - base;
                if (!ransomNote[index]) {
                    return false;
                }
                ransomNote[index]--;
            }
            return true;
        }

    </script>
</body>

</html>